import request from '@/utils/request'

// 树
export function managementCatalogTree(query) {
  return request({
    url: '/data/resource/management/catalogTree',
    method: 'get',
    params: query
  })
}
// 新增数据目录
export function managementAddCatalog(query) {
  return request({
    url: '/data/resource/management/addCatalog',
    method: 'post',
    data: query
  })
}

// 根据资源目录大类统计小类数量
export function mapCountByParent(query) {
  return request({
    url: '/data/resource/map/getTotalStatistics',
    // url: '/data/resource/map/countByParent',
    method: 'get',
    params: query
  })
}

// 查询数据目录列表
export function managementListCatalogs(query) {
  return request({
    url: '/data/resource/management/listCatalogs',
    method: 'get',
    params: query
  })
}

// 获取目录详细信息
export function managementGetCatalog(query) {
  return request({
    url: '/data/resource/management/getCatalog',
    method: 'get',
    params: query
  })
}

// 移动数据目录
export function managementMoveCatalog(query) {
  return request({
    url: '/data/resource/management/moveCatalog',
    method: 'put',
    data: query
  })
}

// 删除数据目录
export function removeCatalog(query) {
  return request({
    url: '/data/resource/management/removeCatalog',
    method: 'delete',
    params: query
  })
}

// 标记数据目录
export function managementMarkCatalog(query) {
  return request({
    url: '/data/resource/management/markCatalog',
    method: 'post',
    data: query
  })
}

// 判断是否已经标记数据目录
export function managementIsMarkCatalog(query) {
  return request({
    url: '/data/resource/management/isMarkCatalog',
    method: 'get',
    params: query
  })
}
// 获取数据目录标记信息
export function managementGetCatalogMark(query) {
  return request({
    url: '/data/resource/management/getCatalogMark',
    method: 'get',
    params: query
  })
}

// 删除标记数据目录
export function removeMarkCatalog(query) {
  return request({
    url: '/data/resource/management/removeMarkCatalog',
    method: 'delete',
    params: query
  })
}

// 根据字典类型查询字典数据信息/system/dict/data/type/{dictType}
export function dictDataTtpe(dictType) {
  return request({
    url: `/system/dict/data/type/${dictType}`,
    method: 'get'
  })
}

// 新建表信息
export function managementCreateTable(query) {
  return request({
    url: '/data/resource/management/createTable',
    method: 'post',
    data: query
  })
}

// /data/resource/management/isExistTable
export function managementIsExistTable(query) {
  return request({
    url: '/data/resource/management/isExistTable',
    method: 'get',
    params: query
  })
}

// 查询表信息
export function managementGetTable(query) {
  return request({
    url: '/data/resource/management/getTable',
    method: 'get',
    params: query
  })
}
// 修改表信息
export function managementAlterTable(query) {
  return request({
    url: '/data/resource/management/alterTable',
    method: 'post',
    data: query
  })
}

// 删除表信息
export function managementRemoveTable(query) {
  return request({
    url: '/data/resource/management/removeTable',
    method: 'delete',
    params: query
  })
}

// 分页查询表记录信息
export function managementPageRecords(query) {
  return request({
    url: '/data/resource/management/pageRecords',
    method: 'post',
    data: query
  })
}

// 新增表记录信息
export function managementAddRecords(query) {
  return request({
    url: '/data/resource/management/addRecords',
    method: 'post',
    data: query
  })
}

// /system/area/treeselect
export function areaTreeselect(query) {
  return request({
    url: '/system/area/treeselect',
    method: 'get',
    params: query
  })
}

// /data/resource/management/getRecord
export function managementGetRecord(catalogId, id) {
  return request({
    url: `/data/resource/management/getRecord/${catalogId}/${id}`,
    method: 'get'
  })
}

// /data/resource/management/removeRecords
export function managementRemoveRecords(query) {
  return request({
    url: '/data/resource/management/removeRecords',
    method: 'delete',
    params: query
  })
}

// /data/resource/management/updateRecords
export function managementUpdateRecords(query) {
  return request({
    url: '/data/resource/management/updateRecords',
    method: 'put',
    data: query
  })
}
// /data/resource/management/upload
export function managementUpload(query) {
  return request({
    url: '/data/resource/management/upload',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: query
  })
}

// 模板下载
export function managementModel(query) {
  return request({
    url: '/data/resource/management/model',
    method: 'get',
    responseType: 'blob',
    params: query
  })
}

// 删除数据目录关联文档文件
export function managementRemoveCatalogFile(query) {
  return request({
    url: '/data/resource/management/removeCatalogFile',
    method: 'delete',
    params: query
  })
}

// 下载数据目录关联文档文件
export function downloadCatalogFile(query) {
  return request({
    url: '/data/resource/management/downloadCatalogFile',
    method: 'get',
    responseType: 'blob',
    params: query
  })
}

export function getPieChart(query) {
  return request({
    url: '/data/resource/map/getPieChart',
    method: 'get',
    params: query
  })
}
